#include<iostream>
using namespace std;

int main() {
	for(int i = 1000; i < 10000; i++) {
		int num = i;
		int sum = 0;
		while(num) {
			int temp = num % 10;
			sum += temp * temp * temp * temp;
			num /= 10; 
		}
		if(sum == i) {
			cout << sum << endl;
		}
	}
	return 0;
}
	
